<?php
namespace app\common\model;
use think\Model;
use think\Db;
class Judge extends Model
{  
	protected $autoWriteTimestamp=true;
	//获取与judge有关的所有信息
	public function getAll()
	{
		$result=Db::name('judge x')
                   ->join('user u','x.uid=u.id')
                   ->join('message m','x.mid=m.id')
                   ->join('user j','x.jid=j.id')
                   ->field(['x.id'=>'id','mid','mname','u.id'=>'uid','u.uname'=>'uname','jid','j.uname'=>'jname','x.create_time'=>'create_time','content','zan'])
                   ->paginate(4); 
		return $result;
	}
    
  
    

   //根据mname查找信息
   public function getAllByMname($str)
    {
        $result=Db::name('judge x')
                   ->join('user u','x.uid=u.id')
                   ->join('message m','x.mid=m.id')
                   ->join('user j','x.jid=j.id')
                   ->where("mname","like","$str")
                   ->field(['x.id'=>'id','mid','mname','u.id'=>'uid','u.uname'=>'uname','jid','j.uname'=>'jname','x.create_time'=>'create_time','content','zan'])
                   ->paginate(4); 
        return $result;
    }

    //根据mid查找信息
   public function getAllById($id)
    {
        $result=Db::name('judge x')
                   ->join('user u','x.uid=u.id')
                   ->join('message m','x.mid=m.id')
                   ->join('user j','x.jid=j.id')
                   ->where("m.id",$id)
                   ->field(['x.id'=>'id','mid','mname','u.id'=>'uid','u.uname'=>'uname','jid','j.image'=>'image','j.uname'=>'jname','x.create_time'=>'create_time','content','zan'])
                   ->order("zan desc")
                   ->select(); 
        return $result;
    }
    
    

}